<?php 
	
	$tinhBUS =  new TinhBUS();
	$vungBUS = new VungBUS();
	$sanphamBUS= new SanPhamBUS();
	$dmspBUS = new DanhMucSPBUS();
	$dmsp = $dmspBUS->getDanhMucSP();
	
	$vung = $vungBUS->getVung();
	
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" type="text/css" href="../css/timkiem.css"/>
</head>

<body>
 <?php
 $idht = 6;
	if(isset($_POST["bttk"]))
	{
		if(isset($_POST["giatu"])==NULL)
		{
			?>
			<script>
				alert("bạn chưa nhập nội dung ");
			</script>
			<?php
		}
		else
		{
			$texttk =$_POST["texttk"];
			$vungtk = $_POST["vungtk"];
			$sptk = $_POST["sanphamtk"];
			$loai = $_POST["loai"];
			$giatu= $_POST["giatu"];
			$giden= $_POST["giaden"];
			if(isset($_POST["sanPhamtk"]))
			if($vungtk>1000 && $sptk >1000)
				$idht = 7;
			if($vungtk<1000 && $sptk >1000)
				$idht = 8;
			if($vungtk>1000 && $sptk < 1000)
				$idht = 9;
			
		}
	}
		
	?>
<div id="search">
<form action="index.php?idht=<?php echo $idht;?>&&texttk=<?php echo $texttk;?>&&loai=<?php echo $loai;?>&&vungtk=<?php echo $vungtk;?>sanphamtk=<?php echo $sptk;?>&&giatu=<?php echo $giatu;?>&&giaden=<?php echo $giden;?>" method="post" name="timkiem">
		<div id="search_fields">		
            <div class="searchmain_top_section">
                <input type="text" alt="q" class="placeholder" title="Tìm Kiếm" placeholder="Tìm Kiếm" value="" id="searchtext" size="20" name="texttk">
                <select class="search_category" id="catgroup" onchange="" name="sanphamtk">
                
                <option value="0">Tất cả danh mục </option>
                		<?php foreach($dmsp as $objdmsp){?>					
                    
                        <option value="<?php echo $objdmsp->getMaDMSP();?>" style="text-align:center;background-color:#dcdcc3; font-weight: bold;">-- <?php echo $objdmsp->getTenDMSP();?> --</option>
                        <?php $sp = $sanphamBUS->getSanPhamByMaDMSP($objdmsp->getMaDMSP());
						if($sp!=NULL){
							foreach($sp as $objsp){?>	 
                    
                        	<option value="<?php echo $objsp->getMaSP();?>"><?php echo $objsp->getTenSP();?> </option>		                           
                    <?php }}}?>                    			 
                    
                
                </select>		
                
                <span>	
                <div id="where" class="featurebox">
                    <select onchange="" style="display:inline;" id="searcharea_expanded" name="vungtk">
                    	<option value="0">Tất cả các vùng </option>
                        <?php foreach($vung as $objvung){?>	
                        				
                    
                        <option  value="<?php echo $objvung->getMaVung();?>" style="background-color:#dcdcc3; font-weight: bold;">-- <?php echo $objvung->getTenVung();?> --</option>
                        <?php $tinh = $tinhBUS->getTinhByMaVung($objvung->getMaVung());
						if($tinh!=NULL){
							foreach($tinh as $objtinh){?>	 
                    
                        	<option value="<?php echo $objtinh->getMaTinh();?>">  <?php echo $objtinh->getTenTinh();?> </option>		
                           
                    <?php }}}?>  
                            
                    </select>  
                </div>
                </span>
                <input type="submit" name="bttk" onclick="" value="Tìm" title="a" id="searchbutton">
            </div>
		
            <div id="types" class="featurebox" style="display: block;">
                
                    <input type="text" alt="q" class="placeholder" title="Giá Từ" placeholder="Giá Từ" value="" id="giatu" size="15" name="giatu">
                     
                    <input type="text" alt="q" class="placeholder" title="Giá Đến" placeholder="Giá Đến" value="" id="giaden" size="15" name="giaden">
            </div>	
			
            <div id="searchextras">		
                        
                <div class="featurebox_col">
                        <div class="featurebox" id="pricelist_0" >
                           <input type="radio"   onclick="" value="0" name="loai" id="type_a">
                            <label   for="type_a" id="label_st_a" class="radio st_label">&nbsp;Tất cả</label>
                        <input type="radio"   onclick="" value="11" name="st" id="type_s">
                            <label for="type_s" id="label_st_s" class="radio st_label">&nbsp;Cần bán</label>
                        <input type="radio"    value="2" onclick="" name="loai" id="type_u">
                            <label   for="type_u" id="label_st_u" class="radio st_label">&nbsp;Cho thuê</label>
                        <input type="radio" value="3" onclick="" name="loai" id="type_k">
                            <label for="type_k" id="label_st_k" class="radio st_label">&nbsp;Cần mua</label>
                        <input type="radio" value="4" onclick="" name="loai" id="type_h">
                            <label  for="type_h" id="label_st_h" class="radio st_label">&nbsp;Cần thuê</label>
                        </div>  
                                             
                 </div>
                
                <div class="featurebox_col">                 
                </div>	
            
            </div>
            <div class="clear"></div>		
            <div id="searchbox_tip" class="searchbox_tip">				
            </div>	
            <div class="banner"><!-- Banner start -->
            </div><!-- Banner end -->	
		</div>
	<div class="clear"></div>
    </form>
   
</div>
</body>
</html>